package com.zzk.lanouhn.myapplication1.adapters;


import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.zzk.lanouhn.myapplication1.R;
import com.zzk.lanouhn.myapplication1.modles.FindDetailsModle;
import com.zzk.lanouhn.myapplication1.modles.FindLunboDetailsModle;

/**
 * 已经没用的适配器，可是就是不想删
 * Created by lanouhn on 16/9/5.
 */
public class FindDetailsLiAdapter extends RecyclerView.Adapter<FindDetailsLiAdapter.MyLiViewHolder> {

    private Context mContext;
    private FindDetailsModle.TripDaysBean findDetailsModle;

    private FindDetailsZuiLiAdapter zuiLiAdapter;

    public FindDetailsLiAdapter(Context mContext, FindDetailsModle.TripDaysBean findDetailsModle) {
        this.mContext = mContext;
        this.findDetailsModle = findDetailsModle;
    }

    @Override
    public MyLiViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_find_details_li, null);
        MyLiViewHolder viewHolder = new MyLiViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(MyLiViewHolder holder, int position) {

        if (findDetailsModle.getNodes().get(position).getEntry_name()==null) {
            holder.llzhuti.setVisibility(View.GONE);
        } else {
            holder.llzhuti.setVisibility(View.VISIBLE);
            holder.tv_zhuti.setText(findDetailsModle.getNodes().get(position).getEntry_name() + "");

        }

        RecyclerView recyclerView = new RecyclerView(mContext);
        zuiLiAdapter = new FindDetailsZuiLiAdapter(mContext, findDetailsModle.getNodes().get(position));
        recyclerView.setAdapter(zuiLiAdapter);

        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
        recyclerView.setLayoutManager(linearLayoutManager);
        holder.ll.addView(recyclerView);

    }

    @Override
    public int getItemCount() {
        return findDetailsModle.getNodes().size();
    }

    public class MyLiViewHolder extends RecyclerView.ViewHolder {

        private TextView tv_zhuti;
        private LinearLayout ll,llzhuti;

        public MyLiViewHolder(View itemView) {
            super(itemView);

            tv_zhuti = (TextView) itemView.findViewById(R.id.item_find_details_li_zhuti);
            ll = (LinearLayout) itemView.findViewById(R.id.item_find_details_li_ll);
            llzhuti= (LinearLayout) itemView.findViewById(R.id.item_find_details_li_ll_zhuti);
        }
    }

}
